import { BasicColumn, FormSchema } from '@/components/Table'
import { getAlarmTypeList } from '@/api/alarm/alarm'

export const columns: BasicColumn[] = [
  {
    title: '告警时间',
    dataIndex: 'alarmTime',
    width: 140,
  },
  {
    title: '告警设备',
    dataIndex: ['device', 'name'],
    width: 120,
  },
  {
    title: '告警参数',
    dataIndex: 'alarmPropertyName',
    width: 100,
  },
  {
    title: '告警类型',
    dataIndex: ['alarmType', 'name'],
    width: 90,
  },
  {
    title: '告警值',
    dataIndex: 'alarmValue',
    width: 80,
  },
  {
    title: '处理意见',
    dataIndex: 'processContent',
    width: 140,
  },
  {
    title: '处理人',
    dataIndex: ['processUser', 'userName'],
    width: 90,
    customRender: ({ text }) => text || '-',
  },
  {
    title: '处理时间',
    dataIndex: 'processTime',
    width: 140,
    customRender: ({ text }) => text || '-',
  },
  {
    title: '处理状态',
    dataIndex: 'processStatus',
    width: 80,
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    field: 'deviceName',
    label: '告警设备名称',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: '请输入告警设备名称',
    },
  },
  // {
  //   field: 'alarmTypeId',
  //   label: '告警类型',
  //   component: 'ApiSelect',
  //   colProps: { span: 6 },
  //   componentProps: {
  //     placeholder: '告警类型',
  //     api: getAlarmTypeList,
  //     labelField: 'name',
  //     valueField: 'id',
  //   },
  // },
  {
    field: 'processStatus',
    label: '处理状态',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      placeholder: '处理状态',
      options: [
        {
          label: '已处理',
          value: 1,
          key: 1,
        },
        {
          label: '未处理',
          value: 0,
          key: 0,
        },
      ],
    },
  },
]

export const HandleModalFormSchema: FormSchema[] = [
  {
    label: '处理意见',
    field: 'processContent',
    component: 'InputTextArea',
    required: true,
    componentProps: {
      placeholder: '请输入',
      autoSize: { minRows: 3, maxRows: 5 },
    },
  },
]
